﻿using SUNRPA.CONTROLS.IMPL.domain.attrubutes;
using SUNRPA.CONTROLS.IMPL.domain.constant;
using SUNRPA.CONTROLS.IMPL.domain.flowRunningVar;
using SUNRPA.CONTROLS.IMPL.util;
using System.Collections.Concurrent;

namespace SUNRPA.CONTROLS.IMPL.domain.flowItemParam {
    [Serializable]
    [VarFieldName("WaitEleResult")]
    public class Wait4WebEleNParam : BaseParam {
        private string webObj = "{webPage}";
        private Element webEle;
        //0等待出现，1等待消失
        private int waitType = 0;
        private bool canExpire = true;
        private string waitExpireTime = "20";
        private string waitEleResult = "waitEleResult";
        public bool CanExpire {
            get => canExpire;
            set {
                canExpire = value;
                NotifyPropertyChanged("CanExpire");
            }
        }

        public string WaitEleResult {
            get => waitEleResult;
            set {
                waitEleResult = value;
                NotifyPropertyChanged("WaitEleResult");
            }
        } 

        public string WebObj {
            get => webObj;
            set {
                webObj = value;
                NotifyPropertyChanged("WebObj");
            }
        }
        public Element WebEle {
            get => webEle;
            set {
                webEle = value;
                NotifyPropertyChanged("WebEle");
            }
        }

        public string WaitExpireTime {
            get => waitExpireTime; 
            set { 
                waitExpireTime = value;
                NotifyPropertyChanged("WaitExpireTime");
            }  
        }

        public int WaitType {
            get => waitType; 
            set { 
                waitType = value;
                NotifyPropertyChanged("WaitType");
            }  
        }

        public string GetTranslateWaitType() {
            switch(this.waitType) {
                case 0:
                    return "出现";
                    break;
                case 1:
                    return "消失";
                    break;
                default:
                    return "出现";
                    break;
            }
        }

        public override void SetLatestVarName(ConcurrentDictionary<string, ConcurrentDictionary<string, RPAVariableDefineWrapper>> globleData) {
            this.waitEleResult = this.GetLatestName(this.waitEleResult, globleData);
        }
    }
}
